package org.seven.jrdp.biz.sys.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.seven.jrdp.biz.sys.mapper.SysParamMapper;
import org.seven.jrdp.biz.sys.model.SysParam;

import com.github.pagehelper.PageHelper;

@Service
public class SysParamService {
	@Autowired
	private SysParamMapper sysParamMapper;
	
	@Transactional(readOnly = true)
	public Map<String, String> getParamMap() {
		Map<String, String> map = new HashMap<String, String>();
		List<SysParam> list = sysParamMapper.selectAll();
		for (SysParam sysParam : list) {
			map.put(sysParam.getKey(), sysParam.getValue());
		}
		return map;
	}

	@Transactional(readOnly = true)
	public List<SysParam> find() {
		PageHelper.orderBy("sort_");
		return sysParamMapper.selectAll();
	}

	@Transactional
	public void save(List<SysParam> list) {
		for (SysParam sysParam : list) {
			sysParamMapper.updateByPrimaryKeySelective(sysParam);
		}
	}
}